{extend name='public/layout' /}

{block name="assign"}
{if isset($info)}
{assign name="page_title" value="编辑分类" /}
{else/}
{assign name="page_title" value="新增分类" /}
{/if}
{/block}

{block name='body'}
<div class="layui-card">
	<div class="layui-card-body">
		<form method="post" action="{:url()}" class="layui-form layui-form-edit">
			<input type="hidden" name="id" value="{$info.id|default=0}">
			<input type="hidden" name="http_referer" value="{$Request.server.HTTP_REFERER|default=''}"/>

			<div class="layui-form-item">
				<label class="layui-form-label" for="title"><i class="required"></i>标题</label>
				<div class="layui-input-block">
					<input type="text" id="title" name="title" value="{$info.title|default=''}" placeholder="请输入标题" class="layui-input" lay-verify="required" autocomplete="on"/>
					<div class="layui-form-mid"></div>
				</div>
			</div>

<!--			<div class="layui-form-item">-->
<!--				<label class="layui-form-label" for="name"><i class="required"></i>标识</label>-->
<!--				<div class="layui-input-block">-->
<!--					<input type="text" id="name" name="name" value="{$info.name|default=''}" placeholder="请输入唯一标识" class="layui-input" lay-verify="required"/>-->
<!--					<div class="layui-form-mid">只能是字母、数字和下划线_及破折号-</div>-->
<!--				</div>-->
<!--			</div>-->

			<div class="layui-form-item">
				<label class="layui-form-label" for="pid"><i class="required"></i>父分类</label>
				<div class="layui-input-inline">
					<select id="pid" name="pid" lay-verify="required">
						<option value="">请选择标签</option>
						{volist name='categories' id='vo'}
						<option value="{$vo.id}">{$vo.title|raw}</option>
						{/volist}
					</select>
					<div class="layui-form-mid"></div>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label"><i class="required"></i>封面</label>
				<div class="layui-input-inline">
					<div data-img-uploader="{name:'cover'}" data-path="{$info.cover|default=''}"></div>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label" for="keywords">关键字</label>
				<div class="layui-input-block">
					<input type="text" id="keywords" name="keywords" value="{$info.keywords|default=''}" placeholder="请输入关键字" class="layui-input" lay-verify="required"/>
					<div class="layui-form-mid">SEO优化时使用</div>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label" for="description">简介</label>
				<div class="layui-input-block">
					<textarea id="description" name="description" class="layui-textarea" rows="3" lay-verify="required">{$info.description|default=''}</textarea>
					<div class="layui-form-mid">SEO优化时使用</div>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label" for="status">状态</label>
				<div class="layui-input-inline">
					<input type="hidden" name="status" value="0"/>
					<input type="checkbox" id="status" name="status" value="1" lay-filter="status" lay-skin="switch" lay-text="启用|禁用"/>
					<div class="layui-form-mid"></div>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label" for="sort">排序</label>
				<div class="layui-input-inline">
					<input type="number" id="sort" name="sort" value="{$info.sort|default=0}" class="layui-input" placeholder="请输入排序" lay-verify="required"/>
					<div class="layui-form-mid"></div>
				</div>
			</div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<button type="submit" class="layui-btn layui-btn-danger" data-ajax-post="{target:'.layui-form'}">
						<i class="fa fa-save"></i> 保存
					</button>
					<a href="javascript:history.back();" class="layui-btn layui-btn-primary">取消 </a>
				</div>
			</div>
		</form>
	</div>
</div>
{/block}

{block name='scriptVar'}
console.log($sys)
xin.setValue('#pid',{$info.pid|default=''});
xin.setChecked('#status',{$info.status|default='1'});
{/block}
